package com.lxd.property.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lxd.property.pojo.Pricelist;
import com.lxd.property.service.PricelistService;
import com.lxd.property.utils.Page;

@Controller
@RequestMapping("pricelist")
public class PricelistController {

	@Autowired
	PricelistService pricelistService;

	@RequestMapping(value = "findAllPricelist", method = RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> findAllPricelist(Page util) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("start", util.getStart());
		map.put("rows", util.getRows());

		List<Pricelist> list = pricelistService.findAllPricelist(map);
		Long total = pricelistService.findAllPricelistCount(map);

		Map<String, Object> con = new HashMap<String, Object>();

		con.put("total", total);
		con.put("rows", list);
		return con;

	}

	@RequestMapping(value = "findPricelistById", method = RequestMethod.POST)
	@ResponseBody
	public Pricelist findPricelistById(Integer id) {
		return pricelistService.findPricelistById(id);

	}

	@RequestMapping(value = "upadtePricelist", method = RequestMethod.POST)
	@ResponseBody
	public Boolean upadtePricelist(Pricelist pricelist) {
		return pricelistService.upadtePricelist(pricelist) == 1;
	}
}
